package c.x.jy.wexin.controller;

import c.x.jy.common.annotation.IntoSet;
import c.x.jy.common.annotation.Login;
import c.x.jy.common.exception.RRException;
import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;
import c.x.jy.dao.entity.OrderAwnserEntity;
import c.x.jy.dao.entity.TeacherConfigEntity;
import c.x.jy.service.service.OrderAwnserService;
import c.x.jy.service.service.TeacherConfigService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 咨询内容表  包括 所有聊天记录，问题 咨询 记录
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-25 10:50:05
 */
@RestController
@RequestMapping("wechat/orderawnser")
public class OrderAwnserController {
    @Autowired
    private OrderAwnserService orderAwnserService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    @IntoSet(Includefields={"memberNickname","memberHeadimgurl","teacherName","teacherHeadimgurl"})
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderAwnserService.queryPage(params);

        return R.put(page);
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		OrderAwnserEntity orderAwnser = orderAwnserService.getById(id);

        return R.put(orderAwnser);
    }

    /**
     * 保存
     */
    @Login
    @RequestMapping("/save")
    public R save(@RequestBody OrderAwnserEntity orderAwnser){
            orderAwnserService.save(orderAwnser);

        return R.ok();
    }
    /**
     * 追问
     */
    @Login
    @RequestMapping("/reask")
    public R reask(@RequestBody OrderAwnserEntity orderAwnser){

        orderAwnserService.reask(orderAwnser);

        return R.ok();
    }
    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("order:orderawnser:update")
    public R update(@RequestBody OrderAwnserEntity orderAwnser){
		orderAwnserService.updateById(orderAwnser);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @RequiresPermissions("order:orderawnser:delete")
    public R delete(@PathVariable("id") Long id){
		orderAwnserService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}

